package com.xiaoniu.forum.web.controller;

import java.util.Arrays;
import java.util.Map;

import com.xiaoniu.forum.common.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.xiaoniu.forum.entity.TabbarItemEntity;
import com.xiaoniu.forum.service.TabbarItemService;


/**
 * tabbar下的每个子项
例如：“我的”tabbar下有
|“我的话题”、“我的回复”、“我的收藏”、“浏览历史”等
 *
 * @author xiaoniu
 * @email 55333@qq.com
 * @date 2021-03-18 14:53:32
 */
@RestController
@RequestMapping("forum/tabbaritem")
@Api("tabbaritem管理")
public class TabbarItemController {
    @Autowired
    private TabbarItemService tabbarItemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation("查看列表")
    //@RequiresPermissions("forum:tabbaritem:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tabbarItemService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 多条件查询列表
     */
    @PostMapping("/multiConditList")
    @ApiOperation("多条件查询列表")
    //@RequiresPermissions("forum:tabbaritem:list")
    public R multiConditList(@RequestBody CommonQueryVo queryVo){
        System.out.println(queryVo);
        PageUtils page = tabbarItemService.queryPage(queryVo);
        return R.ok().put("page",page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation("根据ID查看")
    //@RequiresPermissions("forum:tabbaritem:info")
    public R info(@PathVariable("id") String id){
		TabbarItemEntity tabbarItem = tabbarItemService.getById(id);
        return R.ok().put("tabbarItem", tabbarItem);
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation("保存数据")
    //@RequiresPermissions("forum:tabbaritem:save")
    public R save(@RequestBody TabbarItemEntity tabbarItem){
		tabbarItemService.save(tabbarItem);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation("修改数据")
    //@RequiresPermissions("forum:tabbaritem:update")
    public R update(@RequestBody TabbarItemEntity tabbarItem){
		tabbarItemService.updateById(tabbarItem);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation("批量删除")
    //@RequiresPermissions("forum:tabbaritem:delete")
    public R delete(@RequestBody String[] ids){
		tabbarItemService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
